Ext.define('Service.syslog.controller.SysLogController', {
	extend: 'WebOs.ex.DefaultController',
	
	views : [
		'Service.syslog.view.InitContainer',
		'Service.syslog.view.SysLogGrid',
		'Service.syslog.view.SearchWindow'
	],
	
	stores : [
		'Service.syslog.store.PlSyslogStore'
	],
	
	models : [
		'Service.syslog.model.PlSyslogModel'
	],
	
	refs : [
	
	],
	
	init: function() {
		var me=this;
		this.control({
			'button[id=Service_syslog_view_QueryBtn]' : {
				click : me.onQueryBtnClickFire
			},
			'button[id=Service_syslog_view_AdvanceQueryBtn]' : {
				click : me.onAdvanceQueryBtnClickFire
			},
			'button[id=Service_syslog_view_SearchWindow_searchBtn]' : {
				click : me.onSearchWindowConfirmBtnClickFire
			},
			'button[id=Service_syslog_view_SearchWindow_cancelBtn]' : {
				click : me.onCancelWindowConfirmBtnClickFire
			}
			
		});
	},
	
	onCancelWindowConfirmBtnClickFire : function(btn){
		btn.up('window').hide();
	},
	
	onSearchWindowConfirmBtnClickFire : function(btn){
		var me = this;
		var form = btn.up('window').down('form').getForm();
		var store = Ext.getCmp('Service_syslog_view_SysLogGrid').getStore();
		store.addRequestParams(Ext.apply(form.getValues(),{
			module : 'Service_syslog',
			action : 'querySysLogByCondition'
		}));
		store.loadPage(1);
		btn.up('window').hide();
	},
	
	onAdvanceQueryBtnClickFire : function(){
		var win = Ext.getCmp('Service_syslog_view_SearchWindow');
		if(!win){
			win = Ext.create('Service.syslog.view.SearchWindow'); 
		}
		win.show();
	},
	
	onQueryBtnClickFire : function(){
		var store = Ext.getCmp('Service_syslog_view_SysLogGrid').getStore();
		store.resetRequestParams();
		store.loadPage(1);
	}
});
